//
//  BaseViewController.m
//  DuBai
//
//  Created by darktm on 14-2-20.
//  Copyright (c) 2014年 darktm. All rights reserved.
//

#import "BaseViewController.h"

#import <objc/runtime.h>



@interface BaseViewController ()

@end

@implementation BaseViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

-(void)dealloc{
//    [self freeNetWork];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.extendedLayoutIncludesOpaqueBars = NO;
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    
}


-(void)freeNetWork{
    
    unsigned int varCount;
    
    Ivar *vars = class_copyIvarList([self class], &varCount);
    
    for (unsigned int i = 0; i < varCount; i++) {
        Ivar var = vars[i];
        
        NSString *propertyName = [NSString stringWithFormat:@"%s",ivar_getName(var)];
        if ([propertyName hasPrefix:@"_"]) {
            propertyName =[propertyName substringWithRange:NSMakeRange(1, propertyName.length - 1)];
        }
        DLog(@"%@",objc_lookUpClass(ivar_getName(var)));
        
        id className = object_getClass((__bridge id)(var));
        
        if([[WYHttpTask class] isSubclassOfClass:[className class]]){
            WYHttpTask *task = className;
            task.delegate = nil;
        }
        DLog(@"%@",className);
    }
    
    free(vars);
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
